import 'package:json_annotation/json_annotation.dart';

part 'user_info.g.dart';

@JsonSerializable()
class UserInfo {
  final String avatar;
  final String gender;
  final String nickname;

  //@JsonKey(name: 'aaa') //后端传过来的是aaa,我们前端接受的展示是 phone = aaa
  final String phone;
  final int id;

  UserInfo(this.avatar, this.gender, this.nickname, this.phone, this.id);
  // factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
  //       json["avatar"] as String,
  //       json["gender"] as String,
  //       json["nickname"] as String,
  //       json["phone"] as String,
  //       json["id"] as int,
  //     );
  factory UserInfo.fromJson(Map<String, dynamic> json) =>
      _$UserInfoFromJson(json);

  Map<String, dynamic> toJson(UserInfo instance) => _$UserInfoToJson(this);
}

//半自动化
//执行命令 flutter packages pub run build_runner build
